<?php

namespace app\merchant\controller;

use app\common\model\OrderModel;
use app\common\model\SettlementBillModel;
use app\common\model\WithdrawalCashModel;
use app\common\controller\Tools;
use think\Db;

class Home extends Common
{

    //@todo..  待改版......
    /*首页订单列表
    *@order_id修改的订单编号  order_shipping_status 订单当前物流状态1:全部订单 2：待发货 3：已发货
    * @author houchengyin
    * @time 20170628
    */
    public function index ()
    {
        if(!input('?get.type') || input('get.type') == null){
            $order_shipping_status = 1;
        }else{
            $order_shipping_status = input('get.type');
        }

        switch($order_shipping_status){
            case 1:
                $where['gop.order_status']    = ['eq', 2];
                //$where['order.order_shipping_status'] = ['in', '1,2,3,4,5,6'];
                break;
            case 2:
                $where['order.order_refund_goods_status'] = ['eq', 0];
                $where['gop.order_status']    = ['eq', 2];
                $where['order.order_shipping_status'] = ['eq', 1];
                break;
            case 3:
                $where['gop.order_status']    = ['eq', 2];
                $where['order.order_refund_goods_status'] = ['eq', 0];
                $where['order.order_shipping_status'] = ['in', [5,4]];
                break;
            case 4:
                $where['gop.order_status']    = ['eq', 2];
                $where['order.order_shipping_status'] = ['in', [2,3,4,5]];
                $where['order.order_refund_goods_status'] = ['eq', 2];
                break;
            case 5:
                $where['gop.order_status']    = ['eq', 2];
                $where['order.order_shipping_status'] = ['in', [6,7]];
                break;
            case 6:  //待归还
                $where['gop.order_status']    = ['eq', 2];
                $where['order.order_refund_goods_status'] = ['eq', 0];
                $where['order.order_shipping_status'] = ['in', [2,3]];
                break;
        }
        $where['order.order_merchant_id'] = ['eq', session('merchant.merchant_id')];//['eq', session('merchant.merchant_id')];//,
        $where['order.order_is_delete'] = ['eq', 0];//session('merchant.merchant_id'),
        $page_number = 10;
        //获取快递模板的列表
        $data['merchant_list'] = Db::table('merchant')->where('merchant_id', 'eq', session('merchant.merchant_id'))->find();
        $data['order_list'] = OrderModel::order_sel($where, $page_number);
        //$data['order_list'] = OrderModel::where('order_merchant_id', 'eq', 23)->select();
        $data['page'] = $data['order_list']->render();
        $data['page_list'] = $data['order_list']->total();
        $data['page_number'] = count($data['order_list']);
        $data['type'] = input('get.type');
        return view('index', ['data' => $data]);
    }

}
